home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3.iso / chapte22 / ex3.c < prev    next >
C/C++ Source or Header  |  1995-05-31  |  2KB  |  53 lines

  1. #include <genstub.c>
  2.  
  3. LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  4. {
  5.    switch (uMsg)
  6.    {
  7.          case WM_COMMAND:
  8.                switch ( LOWORD( wParam ) )
  9.                {
  10.                      case IDM_TEST:
  11.                      {
  12.                            int    i;
  13.                            HFONT  hOldFont;
  14.                            TCHAR  szTemp[64];
  15.                            TCHAR  szBuffer[128];
  16.                            static TCHAR szFrench[] = { 0x41, 0xee, 0x6e, 0xe9, 0 };
  17.                            static TCHAR szStart [26] = "Special characters here: ";
  18.                            LPTSTR lpTstr = szTemp;
  19.                            HDC    hDC = GetDC( hWnd );
  20.  
  21.                            lstrcpy( szTemp, szStart );
  22.                            lstrcat( szTemp, szFrench );
  23.                            TextOut( hDC, 0, 0, szBuffer, wsprintf( szBuffer,
  24.                                     "String is [%s]", szTemp ) );
  25.  
  26.                            // advance to char 26, CharNext(0) 25 times...
  27.                            for (i=0; i<26; i++)
  28.                               lpTstr = CharNext(lpTstr );
  29.                            TextOut( hDC, 0, 20, szBuffer,
  30.                               wsprintf( szBuffer, "Char 26 is %c", *lpTstr ) );
  31.  
  32.                            // move back 5 characters
  33.                            for (i=0; i<5; i++)
  34.                               lpTstr = CharPrev( szTemp, lpTstr );
  35.                            TextOut( hDC, 0, 40, szBuffer, wsprintf( szBuffer,
  36.                                     "Char 26-5 is %c", *lpTstr ) );
  37.  
  38.                            ReleaseDC( hWnd, hDC );
  39.                      }
  40.                      break;
  41.                      case IDM_EXIT:
  42.                            DestroyWindow( hWnd );
  43.                      break;
  44.                }
  45.                break;
  46.          case WM_DESTROY:
  47.                PostQuitMessage( 0 );
  48.                break;
  49.          default:
  50.                return (DefWindowProc(hWnd, uMsg, wParam, lParam));
  51.    }
  52.    return (NULL);
  53. }